﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sl.Caching
{
    /// <summary>
    /// 高级缓存
    /// </summary>
    /// <typeparam name="TKey">键</typeparam>
    /// <typeparam name="TResult">返回值</typeparam>
    public interface IDependCache<TKey, TResult> : ICache
    {
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <returns></returns>
        TResult Get(TKey key, Func<TResult> value);
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="idep">依赖缓存项</param>
        /// <returns></returns>
        TResult Get(TKey key, Func<TResult> value, IEnumerable<string> idep);
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="absoluteExpiration">绝对过期时间：设置绝对时间后，相对时间为空</param>
        /// <param name="slidingExpiration">相对过期时间:设置相对时间后，绝对时间为空</param>
        /// <returns></returns>
        TResult Get(TKey key, Func<TResult> value, DateTime? absoluteExpiration, TimeSpan? slidingExpiration);
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="idep">依赖缓存项</param>
        /// <param name="absoluteExpiration">绝对过期时间：设置绝对时间后，相对时间为空</param>
        /// <param name="slidingExpiration">相对过期时间:设置相对时间后，绝对时间为空</param>
        /// <returns></returns>
        TResult Get(TKey key, Func<TResult> value, IEnumerable<string> idep, DateTime? absoluteExpiration, TimeSpan? slidingExpiration);
        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="key">键</param>
        void Remove(TKey key);
    }
}
